package main

import (
	"errors"
	"fmt"
	"math"
	"sort"
	"strconv"
)

func main(){
	timePoints := []string{"23:59","00:00"}
	fmt.Println(findMinDifference(timePoints))
}

func findMinDifference(timePoints []string) int {
	if len(timePoints) > 1440 {
		return 0
	}
	cache, min := make([]int, len(timePoints)), math.MaxInt32
	for i := 0; i < len(timePoints); i ++ {
		hour, _ := strconv.Atoi(timePoints[i][0:2])
		minute, _ := strconv.Atoi(timePoints[i][3:])
		cache[i] = hour*60 + minute
	}
	sort.Ints(cache)
	for i:=1; i < len(cache); i++{
		min = int(math.Min(float64(min), float64(cache[i] - cache[i-1])))
	}
	return int(math.Min(float64(min), float64(cache[0] + 1440 - cache[len(cache) - 1])))
}

type Queue struct {
	arrs []int
	head, tail int
}

func (q *Queue) IsEmpty()bool {
	return q.head == q.tail
}

func (q *Queue) Size() int {
	return q.tail - q.head
}

func (q *Queue) GetFront() int {
	if q.IsEmpty() {
		panic(errors.New("q is empty"))
	}
	return q.arrs[q.head]
}

func (q *Queue) GetBack() int {
	if q.IsEmpty(){
		panic(errors.New("q is empty"))
	}
	return q.arrs[q.tail-1]
}

// delete head element
func (q *Queue)DeQueue(){
	if q.IsEmpty() {
		panic(errors.New("queue is already empty"))
	} else {
		q.tail --
		q.arrs = q.arrs[1:]
	}
}

// add tail element
func (q *Queue)EnQueue(val int) {
	q.arrs = append(q.arrs,val)
	q.tail ++
}